LanguageExt.Core

LanguageExt.Core Monads State and Environment Monads Writer WriterT

Contents

record WriterT <W, M, A> (Func<W, K<M, (A Value, W Output)>> runWriter) Source #

where M : Monad<M>, SemiAlternative<M>
where W : Monoid<W>

WriterT monad transformer, which adds a modifiable state to a given monad.

Parameters

type S

State type

type M

Given monad trait

type A

Bound value type

param runState

Transducer that represents the transformer operation

Methods

method WriterT<W, M, A> Pure (A value) Source #

Lift a pure value into the monad-transformer

Parameters

param value

Value to lift

returns

WriterT

method WriterT<W, M, A> Write ((A Value, W Output) result) Source #

Construct a writer computation from a (result, output) pair.

The inverse of Run()

Parameters

param result

Result / Output pair

method WriterT<W, M, A> Write (A value, W output) Source #

Construct a writer computation from a (result, output) pair.

The inverse of Run()

Parameters

param result

Result / Output pair

method WriterT<W, M, (A Value, W Output)> Listen () Source #

Writes an item and returns a value at the same time

method WriterT<W, M, (A Value, B Output)> Listens <B> (Func<W, B> f) Source #

Listens executes the action and adds the result of applying f to the output to the value of the computation.

method WriterT<W, M, A> Censor (Func<W, W> f) Source #

Censor executes the action and applies the function f to its output, leaving the return value unchanged.

method WriterT<W, M, A> Lift (Pure<A> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

WriterT

method WriterT<W, M, A> Lift (K<M, A> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

WriterT

method WriterT<W, M, A> Lift (Func<A> f) Source #

Lifts a function into the transformer

Parameters

param f

Function to lift

returns

WriterT

method WriterT<W, M, A> LiftIO (IO<A> ma) Source #

Lifts a an IO monad into the monad

NOTE: If the IO monad isn't the innermost monad of the transformer stack then this will throw an exception.

Parameters

param ma

IO monad to lift

returns

WriterT

method WriterT<W, M1, B> MapT <M1, B> (Func<K<M, (A Value, W Output)>, K<M1, (B Value, W Output)>> f) Source #

where M1 : Monad<M1>, SemiAlternative<M1>

Maps the given monad

Parameters

type M1

Trait of the monad to map to

param f

Mapping function

returns

WriterT

method WriterT<W, M, B> MapM <B> (Func<K<M, A>, K<M, B>> f) Source #

Maps the given monad

Parameters

param f

Mapping function

returns

StateT

method WriterT<W, M, B> Map <B> (Func<A, B> f) Source #

Maps the bound value

Parameters

type B

Target bound value type

param f

Mapping function

returns

WriterT

method WriterT<W, M, B> Select <B> (Func<A, B> f) Source #

Maps the bound value

Parameters

type B

Target bound value type

param f

Mapping transducer

returns

WriterT

method WriterT<W, M, B> Bind <B> (Func<A, K<WriterT<W, M>, B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

WriterT

method WriterT<W, M, B> Bind <B> (Func<A, WriterT<W, M, B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

WriterT

method WriterT<W, M, Unit> Bind <B> (Func<A, Tell<W>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

WriterT

method WriterT<W, M, B> Bind <B> (Func<A, IO<B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

WriterT

method WriterT<W, M, C> SelectMany <B, C> (Func<A, K<WriterT<W, M>, B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

WriterT

method WriterT<W, M, C> SelectMany <B, C> (Func<A, WriterT<W, M, B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

WriterT

method WriterT<W, M, C> SelectMany <B, C> (Func<A, K<M, B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

WriterT

method WriterT<W, M, C> SelectMany <B, C> (Func<A, Pure<B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

WriterT

method WriterT<W, M, C> SelectMany <C> (Func<A, Tell<W>> bind, Func<A, Unit, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

WriterT

method WriterT<W, M, C> SelectMany <B, C> (Func<A, IO<B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

WriterT

method K<M, (A Value, W Output)> Run () Source #

Run the writer

Parameters

returns

Bound monad

Operators

operator | (WriterT<W, M, A> ma, WriterT<W, M, A> mb) Source #

operator | (WriterT<W, M, A> ma, Pure<A> mb) Source #

operator | (Pure<A> ma, WriterT<W, M, A>mb) Source #

operator | (IO<A> ma, WriterT<W, M, A> mb) Source #

class WriterTExtensions Source #

Methods

method WriterT<W, M, A> As <W, M, A> (this K<WriterT<W, M>, A> ma) Source #

where M : Monad<M>, SemiAlternative<M>
where W : Monoid<W>

method WriterT<W, M, A> Flatten <W, M, A> (this WriterT<W, M, WriterT<W, M, A>> mma) Source #

where W : Monoid<W>
where M : Monad<M>, SemiAlternative<M>

Monadic join

method WriterT<W, M, C> SelectMany <W, M, A, B, C> ( this K<M, A> ma, Func<A, K<WriterT<W, M>, B>> bind, Func<A, B, C> project) Source #

where W : Monoid<W>
where M : Monad<M>, SemiAlternative<M>

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

StateT

method WriterT<W, M, C> SelectMany <W, M, A, B, C> ( this K<M, A> ma, Func<A, WriterT<W, M, B>> bind, Func<A, B, C> project) Source #

where W : Monoid<W>
where M : Monad<M>, SemiAlternative<M>

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

StateT

class WriterT <W> Source #

where W : Monoid<W>

MonadWriterT trait implementation for WriterT

Parameters

type S

State environment type

type M

Given monad trait

Methods

method WriterT<W, M, A> lift <M, A> (K<M, A> ma) Source #

where M : Monad<M>, SemiAlternative<M>

class WriterT <W, M> Source #

MonadWriterT trait implementation for WriterT

Parameters

type S

State environment type

type M

Given monad trait

Methods

method WriterT<W, M, A> Pure <A> (A value) Source #

method WriterT<W, M, A> liftIO <A> (IO<A> effect) Source #

Lifts a given monad into the transformer

Parameters

param effect

Monad to lift

returns

WriterT

class WriterT Source #

MonadWriterT trait implementation for WriterT

Parameters

type S

State environment type

type M

Given monad trait

Methods

method WriterT<W, M, B> bind <W, M, A, B> (WriterT<W, M, A> ma, Func<A, WriterT<W, M, B>> f) Source #

where W : Monoid<W>
where M : Monad<M>, SemiAlternative<M>

method WriterT<W, M, B> map <W, M, A, B> (Func<A, B> f, WriterT<W, M, A> ma) Source #

where W : Monoid<W>
where M : Monad<M>, SemiAlternative<M>

method WriterT<W, M, A> Pure <W, M, A> (A value) Source #

where W : Monoid<W>
where M : Monad<M>, SemiAlternative<M>

method WriterT<W, M, B> apply <W, M, A, B> (WriterT<W, M, Func<A, B>> mf, WriterT<W, M, A> ma) Source #

where W : Monoid<W>
where M : Monad<M>, SemiAlternative<M>

method WriterT<W, M, B> action <W, M, A, B> (WriterT<W, M, A> ma, WriterT<W, M, B> mb) Source #

where W : Monoid<W>
where M : Monad<M>, SemiAlternative<M>

method WriterT<W, M, A> lift <W, M, A> (K<M, A> ma) Source #

where W : Monoid<W>
where M : Monad<M>, SemiAlternative<M>

method WriterT<W, M, A> liftIO <W, M, A> (IO<A> effect) Source #

where W : Monoid<W>
where M : Monad<M>, SemiAlternative<M>

Lifts a given monad into the transformer

Parameters

param effect

Monad to lift

returns

WriterT

method WriterT<W, M, Unit> tell <M, W> (W item) Source #

where M : WriterM<M, W>, Monad<M>, SemiAlternative<M>
where W : Monoid<W>

Tell is an action that produces the writer output

Parameters

type W

Writer type

param item

Item to tell

returns

Structure with the told item

method WriterT<W, M, A> write <M, W, A> ((A, W) item) Source #

where M : WriterM<M, W>, Monad<M>, SemiAlternative<M>
where W : Monoid<W>

Writes an item and returns a value at the same time

method WriterT<W, M, A> write <M, W, A> (A value, W item) Source #

where M : WriterM<M, W>, Monad<M>, SemiAlternative<M>
where W : Monoid<W>

Writes an item and returns a value at the same time

method WriterT<W, M, A> pass <M, W, A> (WriterT<W, M, (A Value, Func<W, W> Function)> action) Source #

where M : WriterM<M, W>, Monad<M>, SemiAlternative<M>
where W : Monoid<W>

pass is an action that executes the action, which returns a value and a function; it then returns a the value with the output having been applied to the function.

method WriterT<W, M, (A Value, W Output)> listen <M, W, A> (WriterT<W, M, A> ma) Source #

where M : WriterM<M, W>, Monad<M>, SemiAlternative<M>
where W : Monoid<W>

listen is executes the action ma and adds the result of applying f to the output to the value of the computation.

method WriterT<W, M, (A Value, B Output)> listens <M, W, A, B> (Func<W, B> f, WriterT<W, M, A> ma) Source #

where M : WriterM<M, W>, Monad<M>, SemiAlternative<M>
where W : Monoid<W>

listens is executes the action ma and adds the result of applying f to the output to the value of the computation.

method WriterT<W, M, A> censor <M, W, A> (Func<W, W> f, WriterT<W, M, A> ma) Source #

where M : WriterM<M, W>, Monad<M>, SemiAlternative<M>
where W : Monoid<W>

censor is executes the action ma and applies the function f to its output, leaving the return value unchanged.

class WriterT <W, M> Source #

where M : Monad<M>, SemiAlternative<M>
where W : Monoid<W>

MonadStateT trait implementation for StateT

Parameters

type S

State environment type

type M

Given monad trait